<!--
 * @Author: wangming
 * @Date: 2022-04-20 18:31:33
 * @LastEditors: wangming
 * @LastEditTime: 2022-05-09 18:29:12
 * @FilePath: /hanma-application-designer-fed/src/components/Fullscreen.vue
 * @Description: 
-->
<template>
  <IconPark
    @click.native="requestFullscreen"
    :type="fullscreen ? 'off-screen-one' : 'full-screen-one'"
    size="18"
    fill="#999"
    class="poi lh0"
  ></IconPark>
</template>

<script>
import storeform from "@/store";
import { IconPark } from "@icon-park/vue/es/all";
export default {
  props: ["el"],
  computed: {
    fullscreen() {
      if (!!this.el) {
        return storeform.getters.getfullscreen;
      } else {
        return this.full;
      }
    },
  },
  data() {
    return {
      full: false,
    };
  },
  components: { IconPark },
  methods: {
    async requestFullscreen() {
      if (!!this.el) {
        if (!document.fullscreenElement) {
          document.body.requestFullscreen();
          this.el.classList.add("fullscreen");
        } else {
          document.exitFullscreen();
        }
      } else {
        this.full = !this.full;
        this.$emit("fullChange", this.full);
      }
    },
  },
};
</script>
<style>
.fullscreen {
  object-fit: contain;
  user-select: text;
  position: fixed !important;
  top: 0px !important;
  right: 0px !important;
  bottom: 0px !important;
  left: 0px !important;
  box-sizing: border-box !important;
  min-width: 0px !important;
  max-width: none !important;
  min-height: 0px !important;
  max-height: none !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  margin: 0px !important;
  z-index: 99;
}
</style>